package com.daoeping.action;

import java.util.ArrayList;
import java.util.List;

import com.daoeping.data.Bzn_questionfavgroup;
import com.daoeping.data.Bzn_questionfavorite;
import com.daoeping.domain.JsonData;
import com.daoeping.domain.Page;
import com.daoeping.domain.TableData;
import com.daoeping.data.Usr_user;
import com.daoeping.service.Bzn_questionfavgroupService;
import com.daoeping.service.Bzn_questionfavoriteService;
import com.daoeping.util.ConverntJsonData;
import com.opensymphony.xwork2.ActionContext;

public class Bzn_questionfavoriteAction {
	private Bzn_questionfavorite bzn_questionfavorite;
	private Bzn_questionfavgroup bzn_questionfavgroup;
	private Bzn_questionfavgroupService bzn_questionfavgroupService;
	private Bzn_questionfavoriteService bzn_questionfavoriteService;
	private JsonData jsonData;
	private Page page;
	private TableData tableData;
	
	public Bzn_questionfavgroup getBzn_questionfavgroup() {
		return bzn_questionfavgroup;
	}
	public void setBzn_questionfavgroup(Bzn_questionfavgroup bzn_questionfavgroup) {
		this.bzn_questionfavgroup = bzn_questionfavgroup;
	}
	public Bzn_questionfavgroupService getBzn_questionfavgroupService() {
		return bzn_questionfavgroupService;
	}
	public void setBzn_questionfavgroupService(
			Bzn_questionfavgroupService bzn_questionfavgroupService) {
		this.bzn_questionfavgroupService = bzn_questionfavgroupService;
	}
	public Page getPage() {
		return page;
	}
	public void setPage(Page page) {
		this.page = page;
	}
	public TableData getTableData() {
		return tableData;
	}
	public void setTableData(TableData tableData) {
		this.tableData = tableData;
	}
	public JsonData getJsonData() {
		return jsonData;
	}
	public void setJsonData(JsonData jsonData) {
		this.jsonData = jsonData;
	}
	public Bzn_questionfavorite getBzn_questionfavorite() {
		return bzn_questionfavorite;
	}
	public void setBzn_questionfavorite(Bzn_questionfavorite bzn_questionfavorite) {
		this.bzn_questionfavorite = bzn_questionfavorite;
	}
	public Bzn_questionfavoriteService getBzn_questionfavoriteService() {
		return bzn_questionfavoriteService;
	}
	public void setBzn_questionfavoriteService(Bzn_questionfavoriteService bzn_questionfavoriteService) {
		this.bzn_questionfavoriteService = bzn_questionfavoriteService;
	}
	
	public String addBzn_questionfavorite(){
		jsonData = new JsonData();
		List<String> list = new ArrayList<String>();
		if(bzn_questionfavoriteService.findBzn_questionfavoriteById(bzn_questionfavorite )==null&&bzn_questionfavoriteService.addBzn_questionfavorite(bzn_questionfavorite)){
			list.add("success");
		}else{
			list.add("failure");
		}
		jsonData.setJsonData(new ConverntJsonData().getJsonData(list).toString());
		return "addBzn_questionfavorite";
	}
	public String findAllBzn_questionfavoriteByPage(){
		bzn_questionfavorite.setUsr_user((Usr_user) ActionContext.getContext().getSession().get("user"));
		jsonData = bzn_questionfavoriteService.findAllBzn_questionfavoriteByPage(page, tableData, bzn_questionfavorite);
		return "findAllBzn_questionfavoriteByPage";
	}
	
	public String editBzn_questionfavorite(){
		
		List<String> list = new ArrayList<String>();
		if(bzn_questionfavoriteService.editBzn_questionfavorite(jsonData)){
			list.add("success_move");
			jsonData.setJsonData(new ConverntJsonData().getJsonData(list).toString());
			return "editBzn_questionfavorite";
		}else{
			return "exception";
		}
		
	}
	
	public String delBzn_questionfavorite(){
		List<String> list = new ArrayList<String>();
		if(bzn_questionfavoriteService.delBzn_questionfavorite(jsonData)){
			list.add("success_del");
			jsonData.setJsonData(new ConverntJsonData().getJsonData(list).toString());
			return "delBzn_questionfavorite";
		}else{
			return "exception";
		}
	}
	 
	
}
